package com.ruoyi.miaomiao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.miaomiao.domain.SlidePicture;
import com.ruoyi.miaomiao.service.ISlidePictureService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 轮播图管理Controller
 * 
 * @author ruoyi
 * @date 2022-08-09
 */
@RestController
@RequestMapping("/miaomiao/slidepicture")
public class SlidePictureController extends BaseController
{
    @Autowired
    private ISlidePictureService slidePictureService;

    /**
     * 查询轮播图管理列表
     */
    @PreAuthorize("@ss.hasPermi('miaomiao:slidepicture:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlidePicture slidePicture)
    {
        startPage();
        List<SlidePicture> list = slidePictureService.selectSlidePictureList(slidePicture);
        return getDataTable(list);
    }

    /**
     * 导出轮播图管理列表
     */
    @PreAuthorize("@ss.hasPermi('miaomiao:slidepicture:export')")
    @Log(title = "轮播图管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlidePicture slidePicture)
    {
        List<SlidePicture> list = slidePictureService.selectSlidePictureList(slidePicture);
        ExcelUtil<SlidePicture> util = new ExcelUtil<SlidePicture>(SlidePicture.class);
        util.exportExcel(response, list, "轮播图管理数据");
    }

    /**
     * 获取轮播图管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('miaomiao:slidepicture:query')")
    @GetMapping(value = "/{slidepictureId}")
    public AjaxResult getInfo(@PathVariable("slidepictureId") Long slidepictureId)
    {
        return AjaxResult.success(slidePictureService.selectSlidePictureBySlidepictureId(slidepictureId));
    }

    /**
     * 新增轮播图管理
     */
    @PreAuthorize("@ss.hasPermi('miaomiao:slidepicture:add')")
    @Log(title = "轮播图管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlidePicture slidePicture)
    {
        return toAjax(slidePictureService.insertSlidePicture(slidePicture));
    }

    /**
     * 修改轮播图管理
     */
    @PreAuthorize("@ss.hasPermi('miaomiao:slidepicture:edit')")
    @Log(title = "轮播图管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlidePicture slidePicture)
    {
        return toAjax(slidePictureService.updateSlidePicture(slidePicture));
    }

    /**
     * 删除轮播图管理
     */
    @PreAuthorize("@ss.hasPermi('miaomiao:slidepicture:remove')")
    @Log(title = "轮播图管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{slidepictureIds}")
    public AjaxResult remove(@PathVariable Long[] slidepictureIds)
    {
        return toAjax(slidePictureService.deleteSlidePictureBySlidepictureIds(slidepictureIds));
    }
}
